
N.maintenance2 = N.Class.extend({
    resize: function () {
        // var topheight = $(".container-fluid").height() - $(".content-header").height() - 5;
        var topheight = $('.container-fluid').height() - 20
        var bottomheight = topheight * (1 / 2)
        var boxtop = bottomheight - 120
        var maptop = topheight * (2 / 3) - 60
        var mapbot = topheight * (1 / 3) - 60
        $('.control-size-box').height(boxtop)
        $('.control-size-box-map').height(maptop)
        $('.control-size-box-mapbot').height(mapbot)

        var headheight = $('#table1_wrapper .dataTables_scrollHeadInner').height()
        if (headheight) {
            this.tablbeHeight = boxtop - headheight - 5
            $('#table1_wrapper .dataTables_scrollBody').height(this.tablbeHeight)
        }
        headheight = $('#table2_wrapper .dataTables_scrollHeadInner').height()
        if (headheight) {
            this.tablbeHeight = boxtop - headheight - 5
            $('#table2_wrapper .dataTables_scrollBody').height(this.tablbeHeight)
        }
    },
    pageLoad: function (geography, shiduan, geo_dim, city, area) {
        loading.show()
        if (geography) {
            this.geographyChart(shiduan, geo_dim, city, area)
        } else {
            this.timeChart(shiduan, geo_dim, city, area)
        }
        this.chartTop(shiduan, geo_dim, city, area)
    },
    chartTop: function (shiduan, geo_dim, city, area) {
        var param
        if (geo_dim === '省') {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                area: area
            }
        } else {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                city: city,
                area: area
            }
        }
        $.ajax({
            url: getApiPath() + 'wideTableNew/geographyChart',
            type: 'get',
            data: param,
            cache: false,
            dataType: 'json',
            success: function (result) {
                try {
                    result.reverse()
                    $('#zero_business_rate_7d').text(result[0].zero_business_rate_7d)// 常历时超7天
                    $('#zero_business_rate_1m').text(result[0].zero_business_rate_1m)// 常历时超1个月

                    $('#dim_antenna_comp_num').text(toThousands(result[0].dim_antenna_comp_num))// 合规数量
                    $('#dim_antenna_comp_rate').text(result[0].dim_antenna_comp_rate)// 合规性

                    // $("#high_load_num_volte").text(result[0].high_load_num_volte);//4G低流量小区数
                    // $("#high_load_rate_volte").text(result[0].high_load_rate_volte+"%");//4G低流量小区占比

                    $('#indoor_cell_traffic').text(toThousands(result[0].indoor_cell_traffic ? result[0].indoor_cell_traffic.toFixed(2) : 0))// 室分
                    $('#outdoor_cell_traffic').text(toThousands(result[0].outdoor_cell_traffic ? result[0].outdoor_cell_traffic.toFixed(2) : 0))// 宏站
                    $('#inandoutdoor_cell_traffic_ratio').text(result[0].inandoutdoor_cell_traffic_ratio ? result[0].inandoutdoor_cell_traffic_ratio.toFixed(2) : 0)// 宏站室分比

                    $('#wireless_dumbres_rele_num').text(toThousands(result[0].wireless_dumbres_rele_num))// 关联数
                    $('#wireless_dumbres_rele_rate').text(result[0].wireless_dumbres_rele_rate)// 关联率
                } catch (e) {
                    console.log(e)
                }
                loading.hide()
            }
        })
    },
    geographyChart: function (shiduan, geo_dim, city, area) {
        var param
        if (geo_dim === '省') {
            param = {
                geo_dim: '地市',
                time_dim: shiduan,
                area: area
            }
        } else if (geo_dim === '地市' || geo_dim === '区县') {
            param = {
                geo_dim: '区县',
                time_dim: shiduan,
                city: city,
                area: area != '全量小区' ? area : ''
            }
        }

        $.ajax({
            url: getApiPath() + 'wideTableNew/geographyChart',
            type: 'get',
            data: param,
            cache: false,
            dataType: 'json',
            success: function (result) {
                result.reverse()
                // 横坐标
                var xArr = []
                // 纵坐标
                var zero_business_rate_7d = [], zero_business_rate_1m = [], dim_antenna_comp_num = [], dim_antenna_comp_rate = [], low_traffic_cell_num = [], low_traffic_cell_ratio = [], inandoutdoor_cell_traffic_ratio = [], wireless_dumbres_rele_num = [], wireless_dumbres_rele_rate = []
                $.each(result, function (index, value) {
                    if (value.city != '不详' && value.area != '不详') {
                        if (value.area === '全量小区') {
                            xArr.push(value.city)
                        } else {
                            xArr.push(value.area)
                        }
                        zero_business_rate_7d.push(value.zero_business_rate_7d)
                        zero_business_rate_1m.push(value.zero_business_rate_1m)

                        dim_antenna_comp_num.push(value.dim_antenna_comp_num)
                        dim_antenna_comp_rate.push(value.dim_antenna_comp_rate)

                        low_traffic_cell_num.push(value.num11 ? parseFloat(value.num11.toFixed(0)) : 0)
                        low_traffic_cell_ratio.push(value.num12 ? parseFloat(value.num12.toFixed(2)) : 0.00)

                        inandoutdoor_cell_traffic_ratio.push(value.inandoutdoor_cell_traffic_ratio)

                        wireless_dumbres_rele_num.push(value.wireless_dumbres_rele_num)
                        wireless_dumbres_rele_rate.push(value.wireless_dumbres_rele_rate)
                    }
                })

                // 工单合格率、解决率
                drawColumnCol({
                    id: 'line1',
                    cate: xArr,
                    data: [
                        {
                            name: '超7天(%)',
                            type: 'line',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: zero_business_rate_7d

                        }, {
                            name: '超1个月(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: zero_business_rate_1m

                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // 天线工参合规性
                drawColumnCol({
                    id: 'line2',
                    cate: xArr,
                    XWidth: 1,
                    YWidth: 0,
                    data: [
                        {
                            name: '天线工参合规数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: dim_antenna_comp_num,
                            yAxis: 0

                        }, {
                            name: '天线工参合规性(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: dim_antenna_comp_rate,
                            yAxis: 1

                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // 4G低流量小区
                drawColumnCol({
                    id: 'line4',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: '4G低流量小区数',
                            type: 'column',
                            maxPointWidth: 10,
                            color: N.Util.Theme_colors.blue,
                            data: low_traffic_cell_num,
                            yAxis: 0
                        }, {
                            name: '4G低流量小区占比(%)',
                            type: 'line',
                            maxPointWidth: 10,
                            color: N.Util.Theme_colors.orange,
                            data: low_traffic_cell_ratio,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 0,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: '',
                    layout: 'horizontal',
                    lenabledWidth: 10,
                    chartType: 'column'
                })


                // 室分流量承载效率
                drawColumnCol({
                    id: 'line5',
                    // title: 'NB-IOT RRC连接成功率',
                    cate: xArr,
                    data: [
                        {
                            name: '室分与宏站比',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: inandoutdoor_cell_traffic_ratio
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // 无线哑咨关联
                drawColumnCol({
                    id: 'line6',
                    // title: 'VoLTE下行高丢包\n',
                    cate: xArr,
                    data: [
                        {
                            name: '无线哑咨关联数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: wireless_dumbres_rele_num,
                            yAxis: 0
                        }, {
                            name: '无线哑咨关联率(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: wireless_dumbres_rele_rate,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })
                loading.hide()
            }
        })
    },
    timeChart: function (shiduan, geo_dim, city, area) {
        var param
        if (geo_dim === '省') {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                area: area,
                num: shiduan == 'M' ? 6 : 7
            }
        } else {
            param = {
                geo_dim: geo_dim,
                time_dim: shiduan,
                city: city,
                area: area,
                num: shiduan == 'M' ? 6 : 7
            }
        }
        $.ajax({
            url: getApiPath() + 'wideTableNew/timeChart',
            type: 'get',
            data: param,
            cache: false,
            dataType: 'json',
            success: function (result) {
                result.reverse()
                // 横坐标
                var xArr = []
                // 纵坐标
                var zero_business_rate_7d = [], zero_business_rate_1m = [], dim_antenna_comp_num = [], dim_antenna_comp_rate = [], low_traffic_cell_num = [], low_traffic_cell_ratio = [], inandoutdoor_cell_traffic_ratio = [], wireless_dumbres_rele_num = [], wireless_dumbres_rele_rate = []
                $.each(result, function (index, value) {
                    xArr.push(value.starttime.substr(5, 5))
                    zero_business_rate_7d.push(value.zero_business_rate_7d)
                    zero_business_rate_1m.push(value.zero_business_rate_1m)

                    dim_antenna_comp_num.push(value.dim_antenna_comp_num * 10000)
                    dim_antenna_comp_rate.push(value.dim_antenna_comp_rate)

                    low_traffic_cell_num.push(value.num11 ? parseFloat(value.num11.toFixed(0)) : 0)
                    low_traffic_cell_ratio.push(value.num12 ? parseFloat(value.num12.toFixed(2)) : 0.00)

                    inandoutdoor_cell_traffic_ratio.push(value.inandoutdoor_cell_traffic_ratio)

                    wireless_dumbres_rele_num.push(value.wireless_dumbres_rele_num)
                    wireless_dumbres_rele_rate.push(value.wireless_dumbres_rele_rate)
                })

                // 工单合格率、解决率
                drawColumnCol({
                    id: 'line1',
                    cate: xArr,
                    data: [
                        {
                            name: '超7天(%)',
                            type: 'line',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: zero_business_rate_7d

                        }, {
                            name: '超1个月(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: zero_business_rate_1m

                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // 天线工参合规性
                drawColumnCol({
                    id: 'line2',
                    cate: xArr,
                    XWidth: 1,
                    YWidth: 0,
                    data: [
                        {
                            name: '天线工参合规数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: dim_antenna_comp_num,
                            yAxis: 0

                        }, {
                            name: '天线工参合规性(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: dim_antenna_comp_rate,
                            yAxis: 1

                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // 4G低流量小区
                drawColumnCol({
                    id: 'line4',
                    title: null,
                    cate: xArr,
                    data: [
                        {
                            name: '4G低流量小区数',
                            type: 'column',
                            maxPointWidth: 10,
                            color: N.Util.Theme_colors.blue,
                            data: low_traffic_cell_num,
                            yAxis: 0
                        }, {
                            name: '4G低流量小区占比(%)',
                            type: 'line',
                            maxPointWidth: 10,
                            color: N.Util.Theme_colors.orange,
                            data: low_traffic_cell_ratio,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 0,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: '',
                    layout: 'horizontal',
                    lenabledWidth: 10,
                    chartType: 'column'
                })

                // 室分流量承载效率
                drawColumnCol({
                    id: 'line5',
                    // title: 'NB-IOT RRC连接成功率',
                    cate: xArr,
                    data: [
                        {
                            name: '室分与宏站比',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: inandoutdoor_cell_traffic_ratio
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })

                // 无线哑咨关联
                drawColumnCol({
                    id: 'line6',
                    // title: 'VoLTE下行高丢包\n',
                    cate: xArr,
                    data: [
                        {
                            name: '无线哑咨关联数',
                            type: 'column',
                            maxPointWidth: 15,
                            color: N.Util.Theme_colors.blue,
                            data: wireless_dumbres_rele_num,
                            yAxis: 0
                        }, {
                            name: '无线哑咨关联率(%)',
                            type: 'line',
                            marker: {
                                enabled: true, /* 数据点是否显示 */
                                radius: 4 /* 数据点大小px */
                            },
                            color: N.Util.Theme_colors.orange,
                            data: wireless_dumbres_rele_rate,
                            yAxis: 1
                        }
                    ],
                    marginTop: 30,
                    marginBottom: 30,
                    itemWidth: 110,
                    lenabled: true,
                    lenabledAlign: 'center',
                    lenabledVerticalAlign: 'top',
                    layout: 'horizontal'
                })
                loading.hide()
            }
        })
    }
})
var page = new N.maintenance2()

$(function () {
    $(document).on('map:click', function (event, geography, shiduan, geo_dim, map_city, map_area) {
        console.log(geography)
        console.log(shiduan)
        console.log(geo_dim)
        console.log(map_city)
        console.log(map_area)
        page.pageLoad(geography, shiduan, geo_dim, map_city, map_area)
    })
})



